package com.xlh.enums.user;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 用户状态
 * <p>
 * Created by lx on 2019/1/28.
 */
@Getter
@AllArgsConstructor
public enum UserStatusEnum {

    NOT_DELETE(1, "使用"),
    ACCOUNT_CANCELLATION(2, "销户"),
    DELETED(3, "已删除");

    private Integer code;

    private String message;

    public static UserStatusEnum getByCode(Integer code) {
        for (UserStatusEnum statusEnum : UserStatusEnum.values()) {
            if (Objects.equals(statusEnum.getCode(), code)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        UserStatusEnum statusEnum = getByCode(code);
        return statusEnum == null ? null : statusEnum.getMessage();
    }

}
